﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;

namespace MoMoTransferVN_WP.page
{
    public partial class EnterPinPage : PhoneApplicationPage
    {
        public EnterPinPage()
        {
            InitializeComponent();
        }
        protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
        {
            //Do your work here
            if (NavigationService.CanGoBack)
            {
                while (NavigationService.RemoveBackEntry() != null)
                {
                    NavigationService.RemoveBackEntry();
                }
            }
            base.OnBackKeyPress(e);
        }
        private void btnTieptuc_Click(object sender, RoutedEventArgs e)
        {
            
            if ((txtConfirmPin.Password.Length == 0) || (txtConfirmPin.Password.Length == 0))
                return;
            else
            {
                if (txtPin.Password.CompareTo(txtConfirmPin.Password) != 0)
                {
                    messageShow.Visibility = Visibility.Visible;
                    messageShow.txtTitle.Text = "Thông báo!";
                    messageShow.txtContent1.Text = "Mã PIN không khớp, xin nhập lại";
                    messageShow.txtContent2.Visibility = Visibility.Collapsed;
                    messageShow.imgtick.Visibility = Visibility.Collapsed;
                    messageShow.btn1.Visibility = Visibility.Collapsed;
                    messageShow.txt1.Visibility = Visibility.Collapsed;
                    messageShow.btnClose.Content = "Nhập lại";
                    messageShow.btnClose.Click += (s, d) =>
                    {
                        txtPin.Password = string.Empty;
                        txtConfirmPin.Password = string.Empty;
                        this.messageShow.Visibility = Visibility.Collapsed;
                        txtPin.Focus();
                    };
                }
                else
                {

                    this.NavigationService.Navigate((new Uri("/page/RegisterPinPage.xaml", UriKind.Relative)));
                }
            }
                                 
        }

        private void imgDelete1_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            this.txtPin.Password = string.Empty;
        }

        private void imgDelete2_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            this.txtConfirmPin.Password = string.Empty;
            
        }

    }
}